package com.city.service.report.impl;

import com.city.domain.pub.PubFilepath;
import com.city.domain.pub.PubFiletype;
import com.city.domain.report.CtFile;
import com.city.repository.pub.PubFilepathRepository;
import com.city.repository.pub.PubFiletypeRepository;
import com.city.repository.report.CtFileRepository;
import com.city.service.report.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private PubFilepathRepository filepathRepository;
    @Autowired
    private PubFiletypeRepository filetypeRepository;
    @Autowired
    private CtFileRepository fileRepository;

    @Override
    public Integer findTypeIdByExt(String ext) {
        PubFiletype filetype = filetypeRepository.findByExt(ext);
        return filetype.getId();
    }

    @Override
    public PubFilepath saveFilePath(PubFilepath filepath) {
        return filepathRepository.save(filepath);
    }

    @Override
    public CtFile saveFile(CtFile file) {
        return fileRepository.save(file);
    }
}
